﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script>
    var currRowId = 0;
    var status = '@ViewBag.status';
    var number = '@ViewBag.number';
    $(function () {
        initControl();
        partsList();
    });
    function initControl() {
        var myLayout = $('#layout').layout({ resizable: false });
        myLayout.sizePane("west", 300);
        
        if (status == 'I') {
            //$('#trQX').hide();
        } else if (status == 'U' || status == 'D') {
            var data = eval(@Html.Raw(ViewBag.oldEntity));
            setDataByJson("#contentCancle", data, "txtR1");
            setDataByJson("#contentOK", data);
            
            //if (status == 'D') {
            //    $('#trCY').hide();
            //}
        }
        initBindSelect("#form1")
        $('#StartDate').val("@DateTime.Now.ToString("yyyy-MM-dd")");
        $('#StopDate').val("9999-12-31");
    }
    function partsList() {
        var $partsList = $("#partsList");
        $partsList.dataGrid({
            url: "/BOM/Product/GetPartsJson2",
            height: $(window).height() - 120,
            colModel: [
                { label: '零件编号', name: 'FProductionNO', width: 115, align: 'left', sortable: false },
                { label: '零件名称', name: 'FProductionName', width: 166, align: 'left', sortable: false }
            ],
            pager: "#partsPager",
            sortname: 'FProductionNO asc',
            rownumbers: false,
            viewrecords: true,
            loadComplete: function () {
                var ids = $partsList.jqGrid('getDataIDs');
                var length = ids.length;
                if (length > 0) {
                    if (currRowId == 0) {
                        currRowId = 1;
                    } else if (currRowId > length) {
                        currRowId = length;
                    }
                }
                if (currRowId > 0) {
                    if (status == 'I') {
                        $partsList.jqGrid('setSelection', currRowId);
                    }
                }
            },
            onSelectRow: function (rowId) {
                var rowData = $partsList.jqGrid('getRowData', rowId);
                $("#FProductionNO").val(rowData.FProductionNO);
                $("#FProductionName").val(rowData.FProductionName);
                $('#ProductionSumDetail').val("");
            },
            beforeSelectRow: function (rowid, e) {
                
            }
        });
        $("#btn_search").click(function () {
            $partsList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }    
    function btn_ok() {
        submitForm();
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/BOM/Manufacture/SubmitProcessRouteForm?status=" + status + "&keyValue=" + number,
            param: $("#form1").formSerialize(),
            success: function () {
                parent.reloadGrid1();
                parent.$.detailClose();
            }
        })
    }
    function btn_cancel() {
        parent.$.detailClose();
    }
    function btn_assembleline() {
        var title = '输入装配路线';
        var url = '/BOM/Manufacture/ChooseMakeLine?status=0&result=' + $('#AssembleLine').val();
        $.detailOpenTop({
            id: "Detail",
            title: title,
            url: url
        });
    }
    function btn_makeline() {
        var title = '输入制造路线';
        var url = '/BOM/Manufacture/ChooseMakeLine?status=1&result=' + $('#MakeLine').val();
        $.detailOpenTop({
            id: "Detail",
            title: title,
            url: url
        });
    }
    function btn_productionsum() {
        if ($('#FProductionNO').val() == '') {
            $.modalAlert("请先选择产品", "warning");
            return;
        }
        var title = '管理使用件数';
        var url = '/BOM/Manufacture/ProductionSumManage?number=' + $('#FProductionNO').val() + "&name=" + $('#FProductionName').val();
        $.detailOpenTop({
            id: "Detail",
            title: title,
            url: url,
            width: 840
        });
    }
    function do_choose_assembleline(number, text) {
        $('#AssembleLine').val(number);
        $('#AssembleLineName').val(text);
        $.detailCloseTop();
    }
    function do_choose_makeline(number, text) {
        $('#MakeLine').val(number);
        $('#MakeLineName').val(text);
        $.detailCloseTop();
    }
    function do_productionsum(productionsums) {
        $('#ProductionSumDetail').val(productionsums);
        $.detailCloseTop();
        //alert($('#ProductionSumDetail').val());
    }
</script>
<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-west">
        @RenderPage("~/Views/Shared/_CommonStampingList.cshtml")
    </div>
    <div class="ui-layout-center">
        <form id="form1">
            <div style="">
                <table class="form" style="width:900px;text-align:right;margin:2px 15px;border-bottom:2px solid #ccc;">
                    <tr>
                        <td class="formValue" width="180px;">
                            <div class="btn-group dialog-title">
                                输入产品工艺路线更改单
                            </div>
                        </td>
                        <td class="formValue input-width-185" style="width:420px;">
                            技术更改单号 <input id="GGDH" name="GGDH" type="text" class="form-control required" readonly="readonly" value="@ViewBag.ggdh" />
                        </td>
                        <td style="width: 300px; padding: 5px 10px;">
                            <div class="btn-group" style="margin-right:20px;">
                                <a id="" class="btn btn-primary center-block" onclick="btn_ok()"><span class="glyphicon glyphicon-ok"></span> 确认</a>
                            </div>
                            <div class="btn-group">
                                <a id="" class="btn btn-primary center-block" onclick="btn_cancel()"><span class="glyphicon glyphicon-remove"></span> 取消</a>
                            </div>
                        </td>
                    </tr>
                </table>
                <table border="1" style="width: 880px; margin-left: 25px;" >
                    <tr id="trQX">
                        <td style="width:40px;">
                            <div style="width: 16px; margin: 0 auto; font-size: 16px; font-weight: 600; line-height:200%">取消</div>
                        </td>
                        <td style="padding:5px 0;">
                            <table id="contentCancle" class="form">
                                <tr>
                                    <th class="formTitle" style="width:80px;">零件编号</th>
                                    <td class="formValue input-width-210" style="width:220px;">
                                        <input id="txtR1FProductionNO" type="text" class="form-control" disabled="disabled" />
                                    </td>
                                    <th class="formTitle" style="width:80px;">零件名称</th>
                                    <td class="formValue input-width-210" style="width:360px;">
                                        <input id="txtR1FProductionName" type="text" class="form-control" disabled="disabled" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">零件属性</th>
                                    <td class="formValue input-width-140">
                                        <select id="txtR1ProductType" name="" class="form-control" disabled="disabled">
                                            <option value="">&nbsp;</option>
                                            @foreach (var item in ViewBag.productType)
                                            {
                                                <option value="@item.FTypeNO">@item.FTypeNO @item.FTypeName</option>
                                            }
                                        </select>
                                    </td>
                                    <th class="formTitle">使用件数</th>
                                    <td class="formValue input-width-105">
                                        <input id="txtR1ProductionSum" name="" type="text" class="form-control text-right" disabled="disabled"  />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">路线类型</th>
                                    <td class="formValue input-width-105">
                                        <select id="txtR1RouteType" name="" class="form-control" disabled="disabled">
                                            <option value="">&nbsp;</option>
                                            @foreach (var item in ViewBag.routeType)
                                                {
                                                    <option value="@item.FTypeNO">@item.FTypeNO @item.FTypeName</option>
                                                }
                                        </select>
                                    </td>
                                    <th class="formTitle">供货比例</th>
                                    <td class="formValue input-width-105">
                                        <input id="txtR1PurchaseProportion" name="" type="text" class="form-control text-right" disabled="disabled" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">装配路线</th>
                                    <td class="formValue input-width-80">
                                        <div class="input-group">
                                            <input id="txtR1AssembleLine" name="" type="text" class="form-control" disabled="disabled" />
                                        </div>
                                    </td>
                                    <th class="formTitle" style="display:none;">装配路线名称</th>
                                    <td class="formValue input-width-105" style="display:none;">
                                        <input id="txtR1AssembleLineName" name="" type="text" class="form-control" disabled="disabled" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">制造路线</th>
                                    <td class="formValue input-width-185">
                                        <div class="input-group">
                                            <input id="txtR1MakeLine" name="" type="text" class="form-control" disabled="disabled" />
                                        </div>
                                    </td>
                                    <th class="formTitle">制造路线名称</th>
                                    <td class="formValue input-width-320">
                                        <input id="txtR1MakeLineName" name="" type="text" class="form-control" disabled="disabled" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">启用日期</th>
                                    <td class="formValue input-width-185">
                                        <div class="input-group">
                                            <input id="txtR1StartDate" name="" type="text" class="form-control" disabled="disabled" />
                                        </div>
                                    </td>
                                    <th class="formTitle">停用日期</th>
                                    <td class="formValue input-width-185">
                                        <input id="txtR1StopDate" name="" type="text" class="form-control" disabled="disabled" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">备注说明</th>
                                    <td class="formValue input-width-480" colspan="3">
                                        <input id="txtR1CommentExplain" name="" type="text" class="form-control" disabled="disabled" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr id="trCY">
                        <td>
                            <div style="width: 16px; margin: 0 auto; font-size: 16px; font-weight: 600; line-height:200%">采用</div>
                        </td>
                        <td style="padding:5px 0;">
                            <table id="contentOK" class="form">
                                <tr>
                                    <th class="formTitle" style="width:80px;">零件编号</th>
                                    <td class="formValue input-width-210" style="width:240px;">
                                        <input id="FProductionNO" name="FProductionNO" type="text" class="form-control required" readonly="readonly" />
                                        <input id="ProductionID" name="ProductionID" type="hidden" />
                                    </td>
                                    <th class="formTitle" style="width:80px;">零件名称</th>
                                    <td class="formValue input-width-210" style="width:360px;">
                                        <input id="FProductionName" name="FProductionName" type="text" class="form-control" readonly="readonly" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">零件属性</th>
                                    <td class="formValue input-width-140">
                                        <select id="ProductType" name="ProductType" class="form-control">
                                            <option value="">&nbsp;</option>
                                            @foreach (var item in ViewBag.productType)
                                            {
                                                <option value="@item.FTypeNO">@item.FTypeNO @item.FTypeName</option>
                                            }
                                        </select>
                                    </td>
                                    <th class="formTitle">使用件数</th>
                                    <td class="formValue input-width-105">
                                        <input id="ProductionSum" name="ProductionSum" type="text" class="form-control text-right digits" />
                                        <div class="btn-group" style="margin-top:-5px;">
                                            <a id="btn_productionsum" class="btn btn-primary center-block btn-1" onclick="btn_productionsum()"><span class="glyphicon glyphicon-search"></span></a>
                                        </div>
                                        <input type="hidden" id="ProductionSumDetail" name="ProductionSumDetail" value="" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">路线类型</th>
                                    <td class="formValue input-width-105">
                                        <select id="RouteType" name="RouteType" class="form-control">
                                            <option value="">&nbsp;</option>
                                            @foreach (var item in ViewBag.routeType)
                                            {
                                                <option value="@item.FTypeNO">@item.FTypeNO @item.FTypeName</option>
                                            }
                                        </select>
                                    </td>
                                    <th class="formTitle">供货比例</th>
                                    <td class="formValue input-width-105">
                                        <input id="PurchaseProportion" name="PurchaseProportion" type="text" class="form-control text-right number" max="100" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">装配路线</th>
                                    <td class="formValue input-width-80">
                                        <div class="btn-group">
                                            <input id="AssembleLine" name="AssembleLine" type="text" readonly="readonly" class="form-control required">
                                        </div>
                                        <div class="btn-group">
                                            <a id="btn_assembleline" class="btn btn-primary center-block btn-1" onclick="btn_assembleline()"><span class="glyphicon glyphicon-search"></span></a>
                                        </div>
                                    </td>
                                    <th class="formTitle" style="display:none;">装配路线名称</th>
                                    <td class="formValue input-width-105" style="display:none;">
                                        <input id="AssembleLineName" name="AssembleLineName" type="text" readonly="readonly" class="form-control" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">制造路线</th>
                                    <td class="formValue input-width-185">
                                        <div class="btn-group">
                                            <input id="MakeLine" name="MakeLine" type="text" readonly="readonly" class="form-control required">
                                        </div>
                                        <div class="btn-group">
                                            <a id="btn_makeline" class="btn btn-primary center-block btn-1" onclick="btn_makeline()"><span class="glyphicon glyphicon-search"></span></a>
                                        </div>
                                    </td>
                                    <th class="formTitle">制造路线名称 </th>
                                    <td class="formValue input-width-320">
                                        <input id="MakeLineName" name="MakeLineName" type="text" readonly="readonly" class="form-control" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">启用日期</th>
                                    <td class="formValue input-width-185">
                                        <div class="input-group">
                                            <input id="StartDate" name="StartDate" type="text" onclick="WdatePicker({minDate: '1900-01-01', maxDate: '9999-12-31' });" class="form-control input-wdatepicker" value="" />
                                        </div>
                                    </td>
                                    <th class="formTitle">停用日期</th>
                                    <td class="formValue input-width-185">
                                        <input id="StopDate" name="StopDate" type="text" onclick="WdatePicker({ minDate: '1900-01-01', maxDate: '9999-12-31' });" class="form-control input-wdatepicker" value="" />
                                    </td>
                                </tr>
                                <tr>
                                    <th class="formTitle">备注说明</th>
                                    <td class="formValue input-width-480" colspan="3">
                                        <input id="CommentExplain" name="CommentExplain" type="text" class="form-control" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
</div>



